//
//  PlanView.m
//  wangzhe
//
//  Created by 李 佳伟 on 2017/11/22.
//  Copyright © 2017年 李 佳伟. All rights reserved.
//

#import "PlanView.h"
#import "JTCSM.h"

typedef enum {

    xinyongkatype   = 0,
    chuxukatype     = 1,
    yuertype        = 2,
    weixintype      = 3,
    zhifubaotype    = 4,
}zhifutype;


static CGFloat height = 40;
static CGFloat space = 10;
static PlanView *single = nil;

@interface PlanView (){
    MyInfoView *numberview;
    MyInfoView *baozhengView;
    MyInfoView *totalview;
    
    
    MyInfoView *xinyongkaview;
    MyInfoView *chuxukaView;
    MyInfoView *yuerview;
    MyInfoView *weixinview;
    MyInfoView *zhifubaoView;
}

@end

@implementation PlanView

+(PlanView *)shareSingle{
    @synchronized(self){
        if(single == nil){
            
            single =[ [PlanView alloc] init];
        }
        
    }
    return single;
}

- (id)init
{
   self= [super init];
    if (self) {
        self.frame = CGRectMake(0, 0, KSCREENWidth, KSCREENHeight);
        self.backgroundColor = RGBACOLOR(89, 89, 89, .7);
        self.userInteractionEnabled = YES;
        [[JTCSMSingle shareSingle].theWindow addSubview:self];
        CGFloat width = self.frame.size.width-40;
        UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, width, 0)];
        backview.backgroundColor = [UIColor whiteColor];
        [df layerWithView:backview radius:4 width:0 color:nil];
        backview.userInteractionEnabled = YES;
        [self addSubview:backview];
        
        
        UILabel *titleLabel = [UILabel initWithFrame:CGRectMake(space,0 , width-2*space, height) text:@"提交计划详情" font:15 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(193, 192, 193, 1) backgroundColor:nil];
        [backview addSubview:titleLabel];
        [df newlineViewWithHeightofTop:height superView:backview spacing:space*2 color:RGBACOLOR(241, 241, 241, 1) lineHeight:1];
        
        numberview = [[MyInfoView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(titleLabel), width-2*space, height) imagename:nil title:@"计划单号"placeholder:nil isShowLabel:labelType radioBtnIndex:0 GroupId:nil];
        [backview addSubview:numberview];
        
        baozhengView = [[MyInfoView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(numberview), width-2*space, height) imagename:nil title:@"保证金"placeholder:nil isShowLabel:labelType radioBtnIndex:0 GroupId:nil];
        [backview addSubview:baozhengView];
        
        totalview = [[MyInfoView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(baozhengView), width-2*space, height) imagename:nil title:@"支付总金额"placeholder:nil isShowLabel:labelType radioBtnIndex:0 GroupId:nil];
        [backview addSubview:totalview];
        
        UILabel *typeLabel = [UILabel initWithFrame:CGRectMake(space*2,KVIEW_Y(totalview)+20 , width-2*space, height) text:@"支付方式" font:15 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, 1) backgroundColor:nil];
        [backview addSubview:typeLabel];
        
        
        
        xinyongkaview = [[MyInfoView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(typeLabel), width-2*space, height) imagename:@"icon_08@2x.png" title:@"信用卡支付"placeholder:nil isShowLabel:RadioButton radioBtnIndex:xinyongkatype GroupId:@"RadioButtonpay"];
        [backview addSubview:xinyongkaview];

        chuxukaView = [[MyInfoView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(xinyongkaview), width-2*space, height) imagename:@"icon_08@2x.png" title:@"储蓄卡支付"placeholder:nil isShowLabel:RadioButton radioBtnIndex:chuxukatype GroupId:@"RadioButtonpay"];
        [backview addSubview:chuxukaView];

        
        yuerview = [[MyInfoView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(chuxukaView), width-2*space, height) imagename:@"icon_07@2x.png" title:@"账户余额支付"placeholder:nil isShowLabel:RadioButton radioBtnIndex:yuertype GroupId:@"RadioButtonpay"];
        [backview addSubview:yuerview];

        
        weixinview = [[MyInfoView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(yuerview), width-2*space, height) imagename:@"icon_05@2x.png" title:@"微信支付"placeholder:nil isShowLabel:RadioButton radioBtnIndex:weixintype GroupId:@"RadioButtonpay"];
        [backview addSubview:weixinview];

        zhifubaoView = [[MyInfoView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(weixinview), width-2*space, height) imagename:@"icon_06@2x.png" title:@"支付宝支付"placeholder:nil isShowLabel:RadioButton radioBtnIndex:zhifubaotype GroupId:@"RadioButtonpay"];
        [backview addSubview:zhifubaoView];
        
        CGFloat btnspace = 30;
        CGFloat btnHeight = 50;
       UIButton *LoginBtn =[[UIButton alloc] initWithFrame:CGRectMake(btnspace, KVIEW_Y(zhifubaoView)+20 , (width-2*btnspace), btnHeight)];
        LoginBtn.backgroundColor =RGBACOLOR(227, 68, 40, 1);
        [LoginBtn setTitle:@"支付" forState:UIControlStateNormal];
        [LoginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        [LoginBtn addTarget:self action:@selector(gotoMainV) forControlEvents:UIControlEventTouchUpInside];
        LoginBtn.tag = 10002;
        [backview addSubview:LoginBtn];
        [df layerWithView:LoginBtn radius:btnHeight/2 width:0 color:nil];


        [backview setFrame:CGRectMake(0, 0, width, KVIEW_Y(LoginBtn)+20)];
        backview.center = [JTCSMSingle shareSingle].theWindow.center;
        
        [df addTapGestureRecognizerWithTarget:self action:@selector(hiddeSelf) andaddView:self];
        
    }
    
    return self;
}

- (void)hiddeSelf{
    self.hidden = YES;
}

- (void)setvalueWithNumber:(NSString *)number baozhengJin:(NSString *)baozhengjin  total_price:(NSString *)total_price{
    self.hidden = NO;

    numberview.footerLabel.text = [NSString stringWithFormat:@"%@",number];
    baozhengView.footerLabel.text = [NSString stringWithFormat:@"%@",baozhengjin];
    totalview.footerLabel.text = [NSString stringWithFormat:@"%@",total_price];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
